<extend name="Public/base" />
<block name="style">
    <style>
        td{
            padding: 5px 2px!important;
        }
    </style>
</block>
<block name="body">
    <!-- 标题栏 -->
    <div class="main-title">
        <h2> {$title}</h2>
    </div>
    <div ng-controller="DingjiaCtrl" ng-cloak class="ng-cloak" ng-init="dingjiainit()" style="font-size: 2px;">
        <form action="{:U('addprolist')}" id="myform" method="post" class="form-horizontal" style="width: 100%;font-size: small">
            <div class="cf">
                <table class="data-table table-striped" style="width: 100%">
                    <tr>
                        <th>选择采购批次</th>
                        <td>
                            <select select2 class="form-control input-3x" ng-change="batchselect(x)" ng-model="x">
                                <option ng-repeat="b in batchlist">{{b}}</option>
                            </select>
                        </td>
                    </tr>
                </table>
            </div>
            <div class="data-table table-striped" ng-show="olditems.length>0||items.length>0">
                <table>
                    <thead>
                    <tr>
                        <th></th>
                        <th>商品编码</th>
                        <th>商品名称</th>
                        <!--<th>规格</th>-->
                        <!--<th>计算方式</th>-->
                        <th>总件数</th>
                        <th>件价</th>
                        <th>总重</th>
                        <th>每斤单价</th>
                        <th>每件个数</th>
                        <th>每件净重</th>
                        <th>总箱费</th>
                        <th>单箱运费</th>
                        <th>损耗</th>
                        <th>食用率</th>
                        <th>成本</th>
                        <th>世果成本</th>
                        <th>总优惠</th>
                        <th>操作</th>
                    </tr>
                    </thead>
                    <tbody>
                        <tr ng-repeat="item in olditems track by $index">
                            <td></td>
                            <td>
                                <span ng-bind="item.BIN"></span>
                            </td>
                            <td>
                                <span ng-bind="item.pname"></span>
                            </td>
                            <td>
                                <span ng-bind="item.total_num"></span>
                            </td>
                            <td>
                                <span ng-bind="item.unit_num_price"></span>
                            </td>
                            <td>
                                <span ng-bind="item.total_weight"></span>
                            </td>
                            <td>
                                <span ng-bind="item.unit_weight_price"></span>
                            </td>
                            <td>
                                <span ng-bind="item.spec_num"></span>
                            </td>
                            <td>
                                <span ng-bind="item.spec_weight"></span>
                            </td>
                            <td>
                                <span ng-bind="item.total_box_fee"></span>
                            </td>
                            <td>
                                <span ng-bind="item.unit_trans_fee"></span>
                            </td>
                            <td>
                                <span ng-bind="item.loss"></span>
                            </td>
                            <td>
                                <span ng-bind="item.percent"></span>
                            </td>
                            <td>
                                <span ng-bind="item.base_price"></span>
                            </td>
                            <td>
                                <span ng-bind="item.sg_base_price"></span>
                            </td>
                            <td>
                                <span ng-bind="item.cost_off"></span>
                            </td>
                            <td>
                                <span class="btn btn-primary" ng-click="removeOldItems($index)">-</span>
                            </td>
                        </tr>
                        <tr ng-repeat="item in items track by $index">
                            <td>
                                <span class="text-primary">+</span>
                            </td>
                            <td>
                                <input type="text" name="BIN[]" ng-model="item.BIN" class="form-control input-2x">
                            </td>
                            <td>
                                <input type="text" name="pname[]" ng-model="item.pname" class="form-control input-2x"/>
                            </td>
                            <td class="hide">
                                <input type="text" name="spec[]" ng-model="item.spec" class="form-control input-2-x"/>
                            </td>
                            <td class="hide">
                                <input type="text" name="count_type[]" ng-model="item.count_type" class="form-control input-2-x"/>
                            </td>
                            <td>
                                <input type="text" name="total_num[]" ng-model="item.total_num"  class="form-control input-x"/>
                            </td>
                            <td>
                                <input type="text" name="unit_num_price[]" ng-model="item.unit_num_price" value="" class="form-control input-x"/>
                            </td>
                            <td>
                                <input type="text" name="total_weight[]" ng-model="item.total_weight" class="form-control input-2-x"/>
                            </td>
                            <td>
                                <input type="text" name="unit_weight_price[]" ng-model="item.unit_weight_price" class="form-control input-x"/>
                            </td>
                            <td>
                                <input type="text" name="spec_num[]" ng-model="item.spec_num" class="form-control input-x"/>
                            </td>
                            <td>
                                <input type="text" name="spec_weight[]" ng-model="item.spec_weight" class="form-control input-x"/>
                            </td>
                            <td>
                                <input type="text" max="1" name="total_box_fee[]" ng-model="item.total_box_fee"  class="form-control input-x"/>
                            </td>
                            <td>
                                <input type="text" max="1" name="unit_trans_fee[]" ng-model="item.unit_trans_fee" class="form-control input-x"/>
                            </td>
                            <td>
                                <input type="text" name="loss[]" ng-model="item.loss" class="form-control input-2-x"/>
                            </td>
                            <td>
                                <input type="text" name="percent[]" ng-model="item.percent" class="form-control input-x"/>
                            </td>
                            <td>
                                <input type="text" name="base_price[]" ng-model="item.base_price" class="form-control input-2-x"/>
                            </td>
                            <td>
                                <input type="text" name="sg_base_price[]" ng-model="item.sg_base_price" class="form-control input-2-x"/>
                                <input type="text" name="sg_base_pure_price[]" ng-model="item.sg_base_pure_price" class="form-control input-2-x hide"/>
                            </td>
                            <td>
                                <input type="text" name="cost_off[]" ng-model="item.cost_off" class="form-control input-2-x"/>
                            </td>
                            <td>
                                <span class="btn btn-primary" ng-click="remove($index)">-</span>
                            </td>
                        </tr>
                    </tbody>
                </table>
                <div class="col-md-12">
                    <button type="submit" class="ajax-post confirm btn btn-primary" target-form="form-horizontal">保存</button>
                    <a  class="btn btn-success" id="fh" onclick="javascript:history.back(-1); return false;">返 回</a>
                </div>
            </div>
        </form>
        <div class="modal fade" id="exampleModal" tabindex="-1" style="margin:200px;width: 100%;height: 100%" role="dialog" aria-labelledby="exampleModalLabel">
            <div class="modal-dialog" role="document" style="">
            </div>
        </div>
        <div class="modal fade" id="promodal">
            <div class="modal-dialog">
                <div class="modal-content" style="width: 900px;">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                        <h4 class="modal-title">成本定价</h4>
                    </div>
                    <div class="modal-body">
                        <table class="data-table" style="width: 100%">
                            <form id="proform">
                            <tr>
                                <th>商品</th>
                                <td>
                                    <select select2 id="select1" ng-change="proselect(i)" class="form-control input-5x" ng-model="i">
                                        <option ng-repeat="p in plist" value="{{($index)}}">{{p.BIN}}{{p.pname}}[{{p.spec}}]</option>
                                    </select>
                                </td>
                                <th>计算方式</th>
                                <td>
                                    <select  name="style" class="form-control input-3x" ng-model="product.count_type">
                                        <option value="1">箱买斤卖</option>
                                        <option value="2">箱买个卖</option>
                                        <option value="3">斤买斤卖</option>
                                        <option value="4">斤买个卖</option>
                                    </select>
                                </td>
                                <th></th>
                                <td>
                                </td>
                            </tr>
                            </form>
                            <tr>
                                <th>件数：</th>
                                <td><input type="number" name="total_num" ng-model="product.total_num" class="form-control input-3x text-large"/></td>
                                <th>单件价格：</th>
                                <td><input type="number" name="unit_num_price" ng-model="product.unit_num_price" class="form-control input-3x"/></td>
                                <th>每件个数：</th>
                                <td><input type="number" name="spec_num" ng-model="product.spec_num" class="input-3x form-control"/></td>
                            </tr>
                            <tr>
                                <th>总重：</th>
                                <td><input type="number" name="total_weight" ng-model="product.total_weight" class="input-3x form-control"/></td>
                                <th>单价：</th>
                                <td><input type="number" name="unit_weight_price" ng-model="product.unit_weight_price" class=" input-3x form-control"/></td>
                                <th>每件皮重：</th>
                                <td><input ng-change="countSpecWeight()" type="number" name="spec_box_weight" ng-model="product.spec_box_weight" class="input-3x form-control"/></td>
                            </tr>
                            <tr>
                                <th>每件净重：</th>
                                <td><input type="number" name="spec_weight" ng-model="product.spec_weight" class="input-3x form-control"/></td>
                                <th>损耗：</th>
                                <td><input type="number" name="loss" ng-model="product.loss" class="input-3x form-control"/></td>
                                <th>食用率：</th>
                                <td><input type="number" name="percent" ng-model="product.percent" class="input-3x form-control"/></td>
                            </tr>
                            <tr>
                                <th>总箱费：</th>
                                <td><input type="number" name="total_box_fee" ng-model="product.total_box_fee"  class="input-3x form-control"/></td>
                                <th>单箱运费：</th>
                                <td><input type="number" name="unit_trans_fee" ng-model="product.unit_trans_fee" class="input-3x form-control"/></td>
                                <th>优惠(元)：</th>
                                <td><input type="number" name="cost_off" ng-model="product.cost_off" class="input-3x form-control"/></td>
                            </tr>
                            <tbody>
                            </tbody>
                        </table>
                    </div>
                    <div class="modal-footer">
                        <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                        <button type="button" class="btn btn-primary" ng-click="jisuan()">计算成本</button>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <div class="page">
        {$_page}
    </div>
</block>

<block name="script">
    <script type="text/javascript" src="__JS__/dingjia.js"></script>
    <script type="text/javascript">
        //导航高亮
        highlight_subnav('{:U(ACTION_NAME)}');
        $(".time").datetimepicker({
            format: 'Y-m-d'
        });
        $("text").css("font-size",2);
    </script>
</block>
